import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    user: JSON.parse(window.localStorage.getItem('user') || 'null'), // 用户登录状态
    currentRouteMenus: [
      {
        path: '/'
      }
    ]
  },
  mutations: {
    /**
     * @description 设置user
     * @param state
     * @param payload
     */
    setUser (state, payload) {
      state.user = JSON.parse(payload)
      window.localStorage.setItem('user', payload)
    },
    setCurrentRouteMenus (state, payload) {
      state.currentRouteMenus = payload
    }
  },
  actions: {},
  modules: {}
})
